package com.tjsinfo.tjsoa.Dao;
import java.util.Iterator;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class HQLDao extends HibernateDaoSupport implements IHQLDao{
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.QBC.IHQLDao#delete(java.lang.String)
	 */
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.QBC.IHQLDao#executeUpdate(java.lang.String)
	 */
	public void executeUpdate(String sql) {
		Session session = null;
		Transaction transaction  = null;
		try {
			session = getSession();
			transaction =  session.beginTransaction();
			session.createQuery(sql);
			transaction.commit();
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			transaction.rollback();
			
		}
		finally
		{
			session.close();
		}
	}
	public List executeList(String sql) {
		
		return this.getHibernateTemplate().find(sql);
	}
	
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.QBC.IHQLDao#getIterate(java.lang.String)
	 */
	public Iterator getIterate(String sql) {
		Iterator i = getHibernateTemplate().iterate(sql);
		return i;
	}
}
